<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>map映射数组与引用类型的处理</title>
</head>
<body>
   <script>
        // 原数组的元素是值类型，原数组不会被改变    
       let arr = ['xiasnn','xiaxia'];
       let hd = arr.map(function (value) {
           return `beautifal${value}`;
       });
       console.log(arr);
       console.log(hd);

        // 原数组的值为引用类型，原数组会被改变
        let lessons = [
            {title:"响应式布局",lesson:'css'},
            {title:"动画",lesson:'css'},
            {title:"数组",lesson:'js'}
        ];

        // lessons.map(function (value) {
            // return value.price = 100;
        // });
        // console.log(lessons);


        // 如果不想改变原数组
        let houdun = lessons.map(function (value) {
            // 方法一
            // return Object.assign({price:100},value);

            // 方法二
            return {
                title:value.title,
                lesson:value.lesson,
                price:100
            }
        });
        console.log(lessons);
        console.log(houdun);

   </script> 
</body>
</html>